<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;

$this->title = !empty($data['parent'])?$data['parent']->name : $model['title'];
?>
<div class="page">
    <div class="head_banner_bg" style="background-image: url(<?=$model['litpic']?>)">
        <div class="contBox">
            <div class="single-page-banner">
                <h2><?=!empty($data['parent'])?$data['parent']->name : $model['title']?></h2>
            </div>
        </div>
    </div>
    <div class="contBox single-page-content">
        <?php
        if (!empty($data['child'])) {
        ?>
        <ul class="nav nav-pills">
            <?php
            foreach ($data['child'] as $key => $val) {
                if (!empty($val['url']) && $val['url'] != '/') {
                    $url = Yii::$app->urlManager->createUrl([$val['url']]);
                    if (!empty($val['params'])) {
                        $url .= (strpos($url, '?') ? '&'.$val['params'] : '?'.$val['params']);
                    }
                }else{
                    $url = '/';
                }
            ?>
            <li class="<?=$code==$val['code']?'active':''?>" data-single="<?=$val['is_single']?>"><a href="<?=$val['is_single']?'#tab-'.$val['code']:$url?>" <?=$val['is_single']?'data-toggle="tab"':''?>><?=$val['name']?></a></li>
            <?php
            }
            ?>
        </ul>
        <div class="tab-content">
            <?php
            foreach ($data['child'] as $key => $val) {
            ?>
            <div class="tab-pane _shadow <?=$code==$val['code']?'active':''?>" id='tab-<?=$val['code']?>'>
                <div class="single-page-text">
                    <?=$val['page']['content']?>
                    <?php
                    if ($model['code'] == 'feedback') {
                    ?>
                        <p>&nbsp;</p>
                    <?php
                    if ($success == 'True') {
                    ?>
                    <p class="text-success">提交成功</p>
                    <?php
                    }
                    if (!empty($error)) {
                        foreach ($error as $val) {
                    ?>
                    <p class="text-danger"><b><?= join("<br />", $val) ?></b></p>
                    <?php
                        }
                    }
                    ?>
                    <div class="feedback-form">
                        <?php
                        $form = ActiveForm::begin([
                            'id' => 'feedback-form',
//                            'action' => Yii::$app->urlManager->createUrl(['/home/form', 'page' => 'feedback']),
                            'options' => [
                                'class' => 'form-horizontal'
                            ]
                        ])
                        ?>
                        <div class="hidden">
                            <?=$form->field($feedback, 'type')->hiddenInput(['value' => 'feedback'])->label(false)?>
                        </div>
                        <fieldset>
                            <div id="legend" class="">
                                <legend class="">意见反馈</legend>
                            </div>
                            <?=$form->field($feedback, 'user_name')->textInput(['placeholder' => '请输入您的姓名'])?>
                            <?=$form->field($feedback, 'mobile')->textInput(['placeholder' => '请输入您的手机号码'])?>
                            <?=$form->field($feedback, 'email')->textInput(['placeholder' => '请输入您的邮箱'])?>
                            <?=$form->field($feedback, 'content')->textarea(['placeholder' => '请输入您要反馈的内容'])?>
                            <div class="form-group">
                                <?= Html::submitButton('提交', ['class' =>  'btn btn-success']) ?>
                            </div>

                        </fieldset>
                        <?php
                        ActiveForm::end();
                        ?>
                    </div>
                        <?php
                    }
                    ?>
                </div>
            </div>
            <?php
            }
            ?>
        </div>
        <?php
        }else{
        ?>
        <div class="single-page-text" data-code="<?=$model['code']?>">
            <?=$model['content']?>
        </div>
        <?php
        }
        ?>
    </div>
</div>

